package com.example.auth.enums;

import com.example.auth.exception.ServiceError;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 定义业务错误码
 */

@AllArgsConstructor
@Getter
public enum BusinessErrorCode implements ServiceError {

    SYS_ERROR(500,"系统异常"),
    FORBIDDEN_TO_CALL(9000, "禁止调用"),
    ARGS_VALID_ERROR(10001, "参数校验失败"),

    LOGIN_USER_ILLEGAL(10002, "非法登录用户"),
    LOGIN_EXPIRED(10003, "登录已失效"),
    NO_TOKEN_ERROR(10004, "未传入token"),
    NOT_PERMISSION_ERROR(10005, "权限不足"),
    NO_HAVE_LOGIN_USER(10006, "请登录"),
    USER_PHONE_ERROR(10007, "账号或密码错误"),
    TWO_TIME_PWD_ERROR(10008, "两次密码输入不一致"),
    PHONE_EXIST_ERROR(10009, "当前手机号已存在"),
    ;

    private int code;
    private String errMessage;

    public BusinessErrorCode formatErrMessage(Object... params) {
        this.setErrMessage(String.format(this.getErrMessage(), params));
        return this;
    }

    public void setErrMessage(String errMessage) {
        this.errMessage = errMessage;
    }
}
